<html>
<head>
<#assign basePath=request.contextPath>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>后台管理系统</title>
<#include "/WEB-INF/views/template/bootMainCss.ftl" parse=true encoding="utf-8">
    <link href="/bootstrap/css/form.lzy.css" rel="stylesheet">
    <link href="/bootstrap/plugin/bootstrap-datetimepicker/bootstrap-datetimepicker.min.css" rel="stylesheet">
    <style>
        .row{ margin: 0;}
        .search{ float: right;}
        .shop-img{ text-align: left; padding-left: 30px;}
        .shop-img img{ float: left; margin-right: 10px;}
        .shop-img span{ display: block;}
        .name{ text-align: left; padding-left: 30px;}
        .name span{ display: block;}
        #tbodyId{ font-size: 13px;}
        #myTable thead{ font-size: 14px;}
    </style>
</head>
<body>

<div class="panel panel-lzy">
    <div class="panel-body">
        <h5 class="tips-lzy">操作提示</h5>
        <ul class="tips-list-lzy">
            <li>◆&nbsp;<span>该页面显示了所有代言人、代理商、业务员的佣金信息。</span></li>
        </ul>
    </div>
</div>

<!--支付信息-->
<div class="panel panel-lzy">
    <div class="panel-body">
        <div class="cash-info-tip">
            <span>代理商总计:<b id="suOnlinePayTotal">
            <#if voDto.totalSale??>${voDto.totalSale!}
            <#else>0</#if>
            </b></span>
        </div>
        <div class="cash-info-tip">
            <span>成功订单总计:<b id="suOnlinePayTotal">
            <#if voDto.totalProfit??>${voDto.totalProfit!}
            <#else>0</#if>
            </b></span>
        </div>
        <div class="cash-info-tip">
            <span>佣金总额:<b id="suOnlinePayTotal">
            <#if voDto.count??>${voDto.count?c}
            <#else>0</#if>
            </b></span>
        </div>
        <div class="cash-info-tip">
            <span>已提现佣金:<b id="suOnlinePayTotal">
            <#if voDto.dragon??>${voDto.dragon?c}
            <#else>0</#if>
            </b></span>
        </div>
    </div>
</div>

<div class="panel panel-f5">
    <div class="panel-body row">
        <form id="myForm" class="form-inline form-margin-right">
            <div class="panel-body row">
                <div class="form-group">
                    <span>身份类型：</span>
                    <select class="form-control required" id="taxInvoice" name="taxInvoice">
                        <option value="0" >代言人</option>
                        <option value="1" selected="selected">代理商</option>
                        <option value="2">业务员</option>
                    </select>
                </div>
            </div>
            <div class="col-xs-3">
                <div id="start_visit_time" class="input-group date form_datetime col-md-12">
                    <span class="input-group-addon">开始日期</span>
                    <input id="startTime" name="startTime" class="form-control" size="16" type="text" value="" readonly>
                    <span class="input-group-addon"><span class="glyphicon glyphicon-remove"></span></span>
                    <span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span>
                </div>
            </div>
            <div class="col-xs-3">
                <div id="end_visit_time" class="input-group date form_datetime col-md-12">
                    <span class="input-group-addon">结束日期</span>
                    <input id="endTime" name="endTime" class="form-control" size="16" type="text" value="" readonly>
                    <span class="input-group-addon"><span class="glyphicon glyphicon-remove"></span></span>
                    <span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span>
                </div>
            </div>
            <div class="form-group">
                <input type="text" class="form-control" id="key" size="20" placeholder="姓名/手机号">
                <button type="button" class="btn btn-primary btn-sm" onclick="search(1)">&nbsp;&nbsp;查询</button>
            </div>
            <div class="panel-body">
                <button type="button" class="btn btn-primary" onclick="exportOrderList();">导出订单</button>
            </div>
        </form>
    </div>
</div>

<!-- 分页查询的地址-->
<div class="panel-body panel-white">
    <div class="table-responsive">
        <table id="myTable"
               class="table table-hover"
               data-url="${basePath}/admin/product/info/json"
               data-pageSize="10,50,100" data-method="GET">
            <thead>
            <!-- 需要循环的字段  对应mapper文件-->
            <tr>
                <th  data-field="id">序号</th>
                <th  data-field="name" data-call="true" width="10%">姓名</th>
                <th  data-field="phone" data-call="true"  width="25%">手机号</th>
                <th  data-field="price" data-call="true" width="20%">成功订单</th>
                <th  data-field="price" data-call="true" width="15%">佣金总额</th>
                <th  data-field="price" data-call="true" width="15%">已提现佣金</th>
                <th  data-field="button" data-call="true">操作</th>
            </tr>
            </thead>
            <tbody id="tbodyId">
            </tbody>
        </table>
    </div>
    <!-- 分页条-->
    <div class="row">
        <div align="left" class="col-xs-6">
            <div class="input-group">
                <span class="input-group-addon" id="pageCount"></span> <select
                    id="pageSize" onchange="search(1)" class="form-control"
                    style="width: 100px"></select>
            </div>
        </div>
        <div align="right" class="col-xs-6">
            <ul class="pagination" id="pagination"></ul>
        </div>
    </div>
</div>

</div>
<#include "/WEB-INF/views/template/bootMainJs.ftl" parse=true encoding="utf-8">
<script type="text/javascript" src="${basePath}/bootstrap/js/utils.js" type="text/javascript"></script>
<script type="text/javascript" src="${basePath}/bootstrap/plugin/jqPaginator/jqPaginator.js"></script>
<script type="text/javascript" src="${basePath}/bootstrap/plugin/jqPaginator/myPage.js"></script>
<script type="text/javascript" src="${basePath}/bootstrap/plugin/bootstrap-datetimepicker/bootstrap-datetimepicker.min.js"></script>
<script type="text/javascript" src="${basePath}/bootstrap/plugin/bootstrap-datetimepicker/bootstrap-datetimepicker.zh-CN.js"></script>
<script type="text/javascript">

    $('#taxInvoice').on('change',function () {
        var taxInvoiceV = $(this).val();
        if(taxInvoiceV==0){
            window.location.href = "#";
        }else if(taxInvoiceV==1){
            window.location.href = "#";
        }
    });

    //循环列表数据以及操作按钮
    function tableCallBack(data, id){
        if(id == 'button') {//增加操作按钮
            var count = 0;
            var _button = '<button type="button" class="btn btn-white btn-xs" name="' + data.orderId + '" onclick="viewOrder(this);">查看 </button> ';
            count ++
            if(data.minStatus==0){
                _button += '<button type="button" class="btn btn-white btn-xs" onclick="closeSale('
                        + data.orderId +');">关闭</button> ';
                count++;
            }
            return _button;
        }else if(id == "taxInvoice") {
            if (data[id] == '1') {
                return '代言人';
            } else if (data[id] == '2') {
                return '代理商';
            } else if (data[id] == '3') {
                return '业务员';
            }
        }
    }

    //详情
    function viewOrder(obj){
        var id = obj.name;
        window.location.href='${basePath}/admin/order/orderDetail/'+id;
    }
    //关闭订单
    function closeSale(orderId) {
        layer.confirm('是否确定此操作？', {
            btn: ['确定','取消'] //按钮
        }, function() {
            $.ajax({
                type: 'GET',
                url: '${basePath}/admin/order/close?orderId='+orderId,
                dataType: 'json',
                data: {
                },
                success: function (data) {
                    if (data.resultVO.code == '0000') {
                        layer.alert('关闭成功!', {
                            icon: 6
                        }, function(index){
                            layer.closeAll('dialog');
                            location.reload();
                        });
                    }
                }
            });
        });
    }

    //导出
    function exportOrderList(){
        layer.confirm('是否确定此操作？', {
            btn: ['确定','取消'] //按钮
        }, function() {
            var key = $("#key").val();
            window.location.href='${basePath}/admin/order/product/exportOrderList?key='+key;
            layer.closeAll();
        });
    }

    $(function () {
        $('#start_visit_time').datetimepicker({
            minView: "month", //选择日期后，不会再跳转去选择时分秒
            format: "yyyy-mm-dd", //选择日期后，文本框显示的日期格式
            language: 'zh-CN', //汉化
            startDate: new Date(),
            autoclose: true //选择日期后自动关闭
        }).on("changeDate", function () {
            $("#end_visit_time").datetimepicker("setStartDate", $("#startTime").val());
        });

        $('#end_visit_time').datetimepicker({
            minView: "month", //选择日期后，不会再跳转去选择时分秒
            format: "yyyy-mm-dd", //选择日期后，文本框显示的日期格式
            language: 'zh-CN', //汉化
            autoclose: true //选择日期后自动关闭
        }).on("changeDate", function () {
            $("#start_visit_time").datetimepicker("setEndDate", $("#endTime").val());
        });
    })

</script>
</body>
</html>